package com.mllweb.api.core.notice.email;

import com.mllweb.api.core.utils.PropUtils;
import org.springframework.stereotype.Component;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import java.util.Properties;

/**
 * 用户名和密码的验证
 */
@Component
public class MailAuthenticator extends Authenticator {
    private Properties properties;

    public MailAuthenticator() {
        super();
        this.properties = PropUtils.getProperties("email");
    }

    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(properties.getProperty("email.user"), properties.getProperty("email.password"));
    }
}